package com.dfch.auto.appium.ui;

import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.HeadlessException;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class TipWindow extends Frame {


    public TipWindow(String s, String c) throws HeadlessException {
        super(s);
        this.showTip(c);
    }

    public void showTip(String text) {
        this.setLocation(200, 100);
        this.setSize(500, 120);

        Panel panel = new Panel();
        panel.setLayout(new FlowLayout(FlowLayout.CENTER));


        Label label = new Label();
        label.setText(text);
        panel.add(label);

        this.add(panel);


        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent windowEvent) {
                System.exit(0);
            }
        });
        this.setVisible(true);
        this.pack();
    }


    private static String string2Unicode(String string) {
        StringBuffer unicode = new StringBuffer();
        for (int i = 0; i < string.length(); i++) {
            // 取出每一个字符
            char c = string.charAt(i);
            // 转换为unicode
            unicode.append("\\u" + Integer.toHexString(c));
        }
        return unicode.toString();
    }
}
